#include "stdafx.h"
#include "wf_filesaveas.h"

#include "pf_graphic.h"

WF_FileSaveAs::WF_FileSaveAs(PF_Container& container,
        PF_GraphicView& graphicView)
        :PF_ActionInterface("Add Layer", container, graphicView) {}


QAction* WF_FileSaveAs::createGUIAction(LX_Define::ActionType /*type*/, QObject* /*parent*/) {
	// tr("Save Drawing As")
	QAction* action = new QAction(tr("Save &as..."), NULL);
#if QT_VERSION >= 0x040600
        action->setIcon(QIcon::fromTheme("document-save-as", QIcon(":/actions/filesaveas.png")));
#else
        action->setIcon(QIcon(":/actions/filesaveas.png"));
#endif
// SaveAs was itroduces at 4.5 and later
#if QT_VERSION >= 0x040500
	action->setShortcut(QKeySequence::SaveAs);
#endif
    //action->zetStatusTip(tr("Saves the current drawing under a new filename"));
	return action;
}

void WF_FileSaveAs::trigger() {
    PF_DEBUG->print("PF_ActionFileSaveAs::trigger");

    PF_String fileName; // = PF_DIALOGFACTORY->requestFileSaveAsDialog();
    if (graphic!=NULL && !fileName.isEmpty()) {
        graphic->saveAs(fileName, LX_Define::FormatUnknown);
    }
    finish();
}



void WF_FileSaveAs::init(int status) {
    PF_ActionInterface::init(status);
    trigger();
}

// EOF
